home *** CD-ROM | disk | FTP | other *** search
- /* file: RandomDot.c
- puts random dots in its area
- By MGD
- */
-
- #include "busybox.h"
- #define abs(x) ((x <= 0) ? (-x) : (x))
-
-
- /* Guys: It's possible to put some "file-global" data here if you want to share it
- among all the functions in this file. It's up to you if you want */
- static Rect ourRect;
-
-
- void InitRandomDot2Obj(Rect *drawArea, int16 ID) {
- /* You can put various stuffages here - i.e. load string resources, init a brick
- picture, oop ack. */
-
- ourRect = *drawArea;
-
- } /* InitRandomDotObj */
-
-
-
- void DrawRandomDot2Obj(int16 ID) {
- static Point whereLast; /* what the last point drawn was */
-
- int16 i, j, width, height, z;
-
- MoveTo(whereLast.h, whereLast.v);
- width = ourRect.right - ourRect.left;
- height = ourRect.bottom - ourRect.top;
- z = Random();
- i = abs(z) % width;
- z = Random();
- j = abs(z) % height;
- LineTo(i,j);
- whereLast.h = i; whereLast.v = j;
- } /* DrawRandomDotObj */
-
-
-
-